package net.xdclass.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.xdclass.controller.Request.LinkGroupAddRequest;
import net.xdclass.manager.LinkGroupManager;
import net.xdclass.mapper.LinkGroupMapper;
import net.xdclass.model.LinkGroupDO;
import net.xdclass.vo.LinkGroupVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class LinkGroupManagerImpl implements LinkGroupManager {


	@Autowired
	private LinkGroupMapper linkGroupMapper;
	@Override
	public int addGroup(LinkGroupDO linkGroupDO) {
		return   linkGroupMapper.insert(linkGroupDO);
	}
	@Override
	public int delGroup(Long id,Long account) {
		return linkGroupMapper.delete(new QueryWrapper<LinkGroupDO>()
				.eq("id",id).eq("account_no",account));	}
	@Override
	public List<LinkGroupDO> getList(Long accountNo) {
		return linkGroupMapper.selectList(new QueryWrapper<LinkGroupDO>().eq("account_no",accountNo));
	}
	@Override
	public LinkGroupDO getDetail(Long id, long account) {
		return  linkGroupMapper.selectOne(new QueryWrapper<LinkGroupDO>()
				.eq("id",id)
				.eq("account_no",account));
	}

	@Override
	public int update(LinkGroupDO linkGroupDO) {
		return linkGroupMapper.update(linkGroupDO,new QueryWrapper<LinkGroupDO>()
				.eq("account_no",linkGroupDO.getAccountNo()).eq("id",linkGroupDO.getId())
		);
	}
}